cmake_minimum_required(VERSION 2.8.3)
project(kybot_map)

add_compile_options(-std=c++14)

find_package(catkin REQUIRED COMPONENTS
    message_generation   
    roscpp
    roslib
    nav_msgs
    geometry_msgs
    tf
    kybot_msg
)

find_package(OpenCV REQUIRED)


generate_messages(DEPENDENCIES
    std_msgs
    nav_msgs
    geometry_msgs
)

include_directories(
    ${catkin_INCLUDE_DIRS}    
    ${OpenCV_INCLUDE_DIRS}
    include
    # ../bosch_locator_bridge
    # ../../devel/include
)

find_library(GLOG_LIBRARY
  NAMES glog
  PATHS /usr/lib /usr/lib/x86_64-linux-gnu  # 常见库路径
  NO_DEFAULT_PATH
)

if(NOT GLOG_LIBRARY)
  message(FATAL_ERROR "glog library not found. Install with: sudo apt install libgoogle-glog-dev")
endif()

catkin_package(
  CATKIN_DEPENDS
  message_runtime)


add_executable(map_manager_node 
    src/MapManagerNode.cpp
    src/MapManager.cpp
    src/MapIO.cpp
    src/MapInfo.cpp
    src/MapOperation.cpp
    src/LocationSoftwareMapInfo.cpp
    src/LocationSoftwareOperation.cpp
    src/Location3dMapInfo.cpp
    src/Location3dOperation.cpp
)
add_dependencies(map_manager_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(map_manager_node ${catkin_LIBRARIES} ${OpenCV_LIBRARIES} ${GLOG_LIBRARY})

# 设置安装目录 deb打包安装
# set(CMAKE_INSTALL_PREFIX "/home/kybot/kybot_ws/src")


# # Mark executables and/or libraries for installation
# install(TARGETS map_manager_node
#   ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib
#   LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/lib
#   RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/bin
# )

# install(DIRECTORY include/${PROJECT_NAME}/
#    DESTINATION ${CMAKE_INSTALL_PREFIX}/${PROJECT_NAME}/include
#    FILES_MATCHING PATTERN "*.h"
#    PATTERN ".svn" EXCLUDE
#  )

# install(DIRECTORY launch/
#     DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/launch
# )

# install(DIRECTORY  param/
#     DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/param
# )
# 设置安装目录
set(CMAKE_INSTALL_PREFIX "/home/kybot/daimachonggou/install")
install(TARGETS map_manager_node
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/${PROJECT_NAME}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
#启动和配置文件目录
install(DIRECTORY launch data param
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}
)
